package com.headingdata.operator;

public class OperatorDemo1 {
    public static void main(String[] args) {
        System.out.println(1.0+2);
        System.out.println(2.5/2);
        System.out.println(5/2);
        System.out.println(12-10);
        System.out.println(5.0/3);
        System.out.println(1.0*5/2);
        System.out.println(2*2.5);
        System.out.println(3%2);
        System.out.println(10%2);

        //自增、自减
        int a =5;
        ++a;
        System.out.println(a);
        System.out.println(--a);

//        System.out.println(--3);//自增、自减只能操作变量不能操作字面量

        System.out.println("-------------------------------------------------------------------------");
        int i = 11;
        int res = ++i;
        int j = 16;
        int res1 = j++;
        System.out.println(res);
        System.out.println(res1);


        System.out.println("-------------------------------------------------------------------------");

        int m = 5;
        int n = 3;
        // m  5 6 5 4
        // n  3 4 3
        //          6   +  5 + 5 -   4  + 4 + 3
        int res2 = ++m + --m + m-- - ++n + n-- + 3;
        System.out.println(m);
        System.out.println(n);
        System.out.println(res2);

        int c = 10;
        int d = 5;
        // c 10 11 12  11
        // d 5 4
        //          10 +  12 - 4  - 5 +1 + 12
        int res3 = c++ + ++c - --d - ++d +1 + c--;
        System.out.println(c);
        System.out.println(d);
        System.out.println(res3);

    }
}
